package com.example.hospital_208.service.impl;

import com.example.hospital_208.dao.WorkPlanDao;
import com.example.hospital_208.po.WorkPlan;
import com.example.hospital_208.service.WorkPlanService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class WorkPlanServiceImpl implements WorkPlanService {

    private final WorkPlanDao workPlanDao;

    public WorkPlanServiceImpl(WorkPlanDao workPlanDao) {
        this.workPlanDao = workPlanDao;
    }

    @Override
    public int addWorkPlan(WorkPlan workPlan) {
        return workPlanDao.insertWorkPlan(workPlan);
    }

    @Override
    public WorkPlan getWorkPlanByDay(int year, int month, int day) {
        Map<String, Integer> dateParams = new HashMap<>();
        dateParams.put("year", year);
        dateParams.put("month", month);
        dateParams.put("day", day);
        return workPlanDao.selectByDay(dateParams);
    }

    @Override
    public int updateWorkPlanStatus(String day, int status) {
        Map<String, Object> updateParams = new HashMap<>();
        updateParams.put("day", day);
        updateParams.put("status", status);
        return workPlanDao.updateByDay(updateParams);
    }

    @Override
    public List<WorkPlan> getWorkPlanByWeek(String week) {
        return workPlanDao.getWorkPlanByWeek(week);
    }

    @Override
    public WorkPlan getWorkPlanByDay(String day) {
        return workPlanDao.selectAllInfo(day);
    }

    @Override
    public List<WorkPlan> listAllWorkPlans() {
        return workPlanDao.findAllWorkPlans();
    }

    @Override
    public List<WorkPlan> listWorkPlansByDateRange(String startDate, String endDate) {
        return workPlanDao.findWorkPlansByDateRange(startDate, endDate);
    }

    @Override
    public List<WorkPlan> listWorkPlansByStatus(int status) {
        return workPlanDao.findWorkPlansByStatus(status);
    }

    @Override
    public List<String> listAllDays() {
        return workPlanDao.findAllDays();
    }
}